//
//  HomePulseCell.m
//  Ginix
//
//  Created by 冯志强 on 2025/2/23.
//

#import "HomePulseCell.h"

@interface HomePulseCell()
@property (nonatomic,strong) YYLabel * heartLabel;
@property (nonatomic,strong) YYLabel * hrvLabel;
@property (nonatomic,strong) YYLabel * oxLabel;
@property (nonatomic,strong) YYLabel * bodyLabel;
@property (nonatomic,strong) YYLabel * plLabel;
@property (nonatomic,strong) YYLabel * paLabel;
@end

@implementation HomePulseCell

-(void)setSubViewLayout{
    [super setSubViewLayout];
    
    self.titleLabel.text = @"脉象";

    [self addSubview:self.heartLabel];
    [_heartLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_offset(CGSizeMake(140 * FMScaleX, 44 * FMScaleX));
        make.left.equalTo(self.bgview.mas_left).offset(25 * FMScaleX);
        make.top.equalTo(self.iconView.mas_bottom).offset(15 * FMScaleX);
    }];
    [self addSubview:self.hrvLabel];
    [_hrvLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgview.mas_right).offset(-25 * FMScaleX);
        make.size.centerY.equalTo(self.heartLabel);
    }];
    
    [self addSubview:self.oxLabel];
    [_oxLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.heartLabel.mas_bottom).offset(10 * FMScaleX);
        make.size.centerX.equalTo(self.heartLabel);

    }];
    [self addSubview:self.bodyLabel];
    [_bodyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.hrvLabel.mas_bottom).offset(10 * FMScaleX);
        make.size.centerX.equalTo(self.hrvLabel);
    }];
    
    [self addSubview:self.plLabel];
    [_plLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.oxLabel.mas_bottom).offset(10 * FMScaleX);
        make.size.centerX.equalTo(self.oxLabel);

    }];
    [self addSubview:self.paLabel];
    [_paLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.bodyLabel.mas_bottom).offset(10 * FMScaleX);
        make.size.centerX.equalTo(self.bodyLabel);
    }];
}


-(void)setInfoModel:(HomeAllCheckInfoModel *)infoModel{
    
    if (infoModel.maiwei.length > 0) {
        self.heartLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"脉位： " secondString:infoModel.maiwei];
        self.heartLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.maili.length > 0) {
        self.hrvLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"脉力： " secondString:infoModel.maili];
        self.hrvLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.maiguilv.length > 0) {
        self.bodyLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"脉律： " secondString:infoModel.maiguilv];
        self.bodyLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.mailv.length > 0) {
        self.oxLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"脉率： " secondString:infoModel.mailv];
        self.oxLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.maishi1.length > 0) {
        self.plLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"脉势(流利度)： " secondString:[NSString stringWithFormat:@"数(%@)",infoModel.maishi1 ]];
        self.plLabel.textAlignment = NSTextAlignmentCenter;
    }
    if (infoModel.maishi2.length > 0) {
        self.paLabel.attributedText = [NSString formatHealthInfoWithHeartRate:@"脉势(紧张度)： " secondString:infoModel.maishi2];
        self.paLabel.textAlignment = NSTextAlignmentCenter;
    }
    
}

-(YYLabel *)heartLabel{
    
    if (!_heartLabel) {
        _heartLabel = [[YYLabel alloc]init];
        _heartLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_heartLabel setCornerRadius:6 * FMScaleX];
        _heartLabel.textAlignment = NSTextAlignmentCenter;

    }
    return _heartLabel ;
}

-(YYLabel *)hrvLabel{
    
    if (!_hrvLabel) {
        _hrvLabel = [[YYLabel alloc]init];
        _hrvLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_hrvLabel setCornerRadius:6 * FMScaleX];
        _hrvLabel.textAlignment = NSTextAlignmentCenter;

    }
    return _hrvLabel ;
}

-(YYLabel *)oxLabel{
    
    if (!_oxLabel) {
        _oxLabel = [[YYLabel alloc]init];
        _oxLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_oxLabel setCornerRadius:6 * FMScaleX];
        _oxLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _oxLabel ;
}

-(YYLabel *)bodyLabel{
    
    if (!_bodyLabel) {
        _bodyLabel = [[YYLabel alloc]init];
        _bodyLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_bodyLabel setCornerRadius:6 * FMScaleX];
        _bodyLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _bodyLabel ;
}

-(YYLabel *)plLabel{
    
    if (!_plLabel) {
        _plLabel = [[YYLabel alloc]init];
        _plLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_plLabel setCornerRadius:6 * FMScaleX];
        _plLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _plLabel ;
}

-(YYLabel *)paLabel{
    
    if (!_paLabel) {
        _paLabel = [[YYLabel alloc]init];
        _paLabel.backgroundColor = RDRGB(0xF5F2ED);
        [_paLabel setCornerRadius:6 * FMScaleX];
        _paLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _paLabel ;
}

@end
